package com.examples;

import toman.Prop;
import toman.Ref;
import toman.orm.TO;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

@TO(
    id = "a.name=:albumName",
    read = "select a from Album a",
    write = "update Album a set a.name=:albumName")
public class BasicAlbumWithBasicPhotosTO {

    @Prop("name")
    private String albumName;

    @Ref("p.album.name=:albumName")
    private List<BasicPhotoAlbumTO> photoTOs;

    private Calendar albumCreated;

    @Prop("created")
    public void setAlbumCreated(Date albumCreated) {
        this.albumCreated = Calendar.getInstance();
        this.albumCreated.setTime(albumCreated);
    }

    public Calendar getAlbumCreated() {
        return albumCreated;
    }

    public String getAlbumName() {
        return albumName;
    }

    public void setAlbumName(String albumName) {
        this.albumName = albumName;
    }

    public List<BasicPhotoAlbumTO> getPhotoTOs() {
        return photoTOs;
    }
}
